//
//  JPFHttpResponse.h
//  JPFCoreKit
//
//  Created by jpf on 2021/7/28.
//  Copyright © 2021 jpf. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "JPFHttpError.h"

NS_ASSUME_NONNULL_BEGIN


/*!
* @class
* @abstract Http网络请求响应结果
* @version 1.0.0
*/
@interface JPFHttpResponse<T> : NSObject


@property (nonatomic, copy) void (^completion)(BOOL success, T resObj, NSString *message,NSError *error);

//初始化
- (instancetype)initWithCompletion:(void (^)(BOOL success,id _Nullable obj, NSString *mesage,NSError * _Nullable  error))completion;

- (void)setResponse:(NSHTTPURLResponse *)response
               data:(NSData *)data
            message:(NSString *)message
              error:(JPFHttpError *)error;

//处理响应
- (id)responseData;

//原属数据处理
- (id)originalResponseData;

//业务数据处理
- (id)logicResponse;


- (BOOL)isResponseSuccess;

//响应成功，业务逻辑是否成功，默认成功，便于子类统一处理业务
- (BOOL)isLogicResponseSuccess;

//业务数据提示信息
- (NSString *)message;

- (JPFHttpError *)logicError;

@end

NS_ASSUME_NONNULL_END
